﻿using System;
using System.Threading;

namespace ModbusTcpClient
{
    class Program
    {
        static void Main(string[] args)
        {
            ModbusTcp modbusTCP = new ModbusTcp("192.168.1.51", 502, 1);
            modbusTCP.Connect();

            while (true)
            {
                Console.WriteLine($"连接状态:{modbusTCP.IsConnected}");
                if (modbusTCP.IsConnected)
                {
                    modbusTCP.TestForReadWriteMultipleRegisters(0, 100, 100);
                }
                Console.WriteLine();
                Thread.Sleep(2000);
            }
            
        }
    }
}
